using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace TermitesMagnets
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class GameBackground : Microsoft.Xna.Framework.DrawableGameComponent
    {
        private static Texture2D backgroundTexture;
        private GameplayScreen GameScreen;


        public GameBackground(Game game)
            : base(game)
        {
            this.GameScreen = GameplayScreen.GlobalGame;
            // TODO: Construct any child components here
        }

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            // TODO: Add your initialization code here

            base.Initialize();
        }

        public override void Draw(GameTime gameTime)
        {
            Game1.GlobalGame.GraphicsDevice.Clear(ClearOptions.Target,
                                               Color.Black, 0, 0);

            // Our player and enemy are both actually just text strings.
            SpriteBatch spriteBatch = GameplayScreen.GlobalGame.SpriteBatch;

            spriteBatch.Begin();
            spriteBatch.Draw(backgroundTexture,
                        new Rectangle(0, 0, GameScreen.screenWitdh,
                        GameScreen.screenHeight), null,
                        Color.White, 0, Vector2.Zero,
                        SpriteEffects.None, 0);
            spriteBatch.End();
            base.Draw(gameTime);
        }

        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // TODO: Add your update code here

            base.Update(gameTime);
        }

        internal static void LoadContent(ContentManager content)
        {
            backgroundTexture = content.Load<Texture2D>(@"Images\background");
        }
    }
}
